@extends('layout.page')
@section('title','题库管理 - 编辑')

@section('static-page')
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>题库管理 <small>编辑</small></h5>
            </div>
            <div class="ibox-content">
                <form method="post" action="/quetions/doEdit" class="form-horizontal" id="form">
                    {{csrf_field()}}
                    <input type="hidden" name="info[id]" value="{{ $info->id }}">
                    <div class="form-group  ">
                        <label class="col-sm-2 control-label">名称：</label>
                        <div class="col-sm-6">
                            <div class="row">
                                <div class="col-md-8">
                                    <input type="text"  name="info[title]" value="{{ $info->title }}"
                                           placeholder="名称" class="form-control"
                                           @if($errors->has('info.title')) has-error @endif">
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>

                    <div class="form-group ">
                        <label class="col-sm-2 control-label">类型：</label>
                        <div class="col-sm-2">
                            <div class="row">
                                <div class="col-md-12 m-b-xs">
                                    <select  name="info[type]" id="abc" class="form-control input-s-sm inline">
                                        @foreach($types as $key => $val)
                                            <option @if( $val['id'] == $info->type ) selected @endif
                                            value="{{ $val['id'] }}">{{ $val['title']}}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>

                    <div class="form-group  ">
                        <label class="col-sm-2 control-label">简介描述：</label>
                        <div class="col-sm-6">
                            <div class="row">
                                <div class="col-md-8">
                                    <textarea type="text" name="info[description]" rows="5" cols="20"
                                           placeholder="简介描述" class="form-control">{{ $info->description }}</textarea>
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">考试时间：</label>
                        <div class="col-sm-10">
                            <input name="info[exam_time]" readonly
                                   class="form-control layer-date" value="{{ date('Y-m-d',$info->exam_time) }}"
                                   id="_exam-time" onclick="laydate({elem: '#_exam-time'});">

                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>

                    <div class="form-group  ">
                        <label class="col-sm-2 control-label">排序：</label>
                        <div class="col-sm-4">
                            <div class="row">
                                <div class="col-md-6 m-b-xs">
                                    <input type="text" name="info[sort]" value="{{ $info->sort }}"
                                           placeholder="排序" class="form-control">
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>

                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <button class="btn btn-primary" type="submit" id="btn-save">保存内容</button>
                            <a href="javascript:void(0);" onclick="window.history.back()">
                                <button class="btn btn-white" type="button">取消</button>
                            </a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection

@section('javascript')
    <script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="/js/plugins/layer/laydate/laydate.js"></script>
    <script src="/js/plugins/jqueryValidate/jquery.validate.js"></script>
    <script src="/js/webuploader.min.js"></script>
    <script>
        $(document).ready(function () {

            $("#form").validate({
                rules: {
                    'info[title]': "required",
                    'info[exam_time]': "required"
                },
                messages: {
                    'info[title]': "必填项",
                    'info[exam_time]': "必填项"
                }
            });


        });
    </script>
@endsection

